// pages/reportformbox/reportformindex/reportformindex.js
import {
  getReportFormInfo,
  getReportFormInfoForDate
} from '../../../utils/networkRequest.js'
import {
  errorMsg
} from '../../../utils/tool.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataInfo: null,
    monthindex: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let self = this;
    getReportFormInfo((r) => {
      if (r.code == 0) {
        self.setData({
          dataInfo: r.data
        })
      } else {
        errorMsg(r.message)
      }
    })
  },
  //每日订单量
  bindPickerChange1: function(e) {
    let self = this;
    let {
      dataInfo
    } = this.data
    // console.log('picker发送选择改变，携带值为', e.detail.value)
    // this.setData({
    //   monthindex: e.detail.value
    // })

    getReportFormInfoForDate(dataInfo.months[e.detail.value].name, (r) => {
      if (r.code == 0) {
        self.setData({
          ["dataInfo.order_list"]: r.data,
          monthindex: e.detail.value
        })
      } else {
        errorMsg(r.message);
      }
    })
  },
  goDetail: function(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../../myorderbox/orderdetail/orderdetail?oid=' + id,
    })
  }
})